
<div class="layui-row">
    <div class="layui-card-header">
        <div class="left tbt">
            共{$lists->total()}条记录  <span class="x-red" id="onsel" style="display: none;">已选择<span id="onselnum"></span>条</span>
        </div>
        <div class="right">
            {if !$isearch}
            <button class="layui-btn layui-btn-primary addline" onclick="addline()">新增条目</button>
            <button class="layui-btn layui-btn-primary selobj" onclick="sel()" data-type="sel">批量选择</button>
            <button class="layui-btn layui-btn-danger del" onclick="del()">删除</button>
            {else}
            <form action="{:url('cartoon/details')}" id="search" method="get" class="layui-form layui-col-space5 hide">
                <input type="hidden" name="search" value="1">
                <input type="hidden" name="id" value="{$item.id}">
                <input type="hidden" name="sel" value="{$sel}">
                <input type="hidden" name="year">
                <input type="hidden" name="staff">
                <div class="layui-inline layui-show-xs-block">
                    <select name="search_type" lay-filter="search_type">
                        <option value="">筛选条件</option>
                        <option value="year" {if request()->get('search_type') eq 'year'}selected{/if}>按年份</option>
                        <option value="yzmg" {if request()->get('search_type') eq 'yzmg'}selected{/if}>只看原作漫改</option>
                        <option value="dhzyc" {if request()->get('search_type') eq 'dhzyc'}selected{/if}>只看动画组原创</option>
                        <option value="tb" {if request()->get('search_type') eq 'tb'}selected{/if}>只看停播</option>
                        <option value="cb" {if request()->get('search_type') eq 'cb'}selected{/if}>只看重播</option>
                        <option value="25minute" {if request()->get('search_type') eq '25minute'}selected{/if}>只看25分钟篇</option>
                        <option value="teb" {if request()->get('search_type') eq 'teb'}selected{/if}>只看特别篇</option>
                        <option value="tdcyr" {if request()->get('search_type') eq 'tdcyr'}selected{/if}>按特定参与人</option>
                    </select>
                </div>
            </form>
            {/if}
        </div>
    </div>
    <div class="layui-card-body layui-card-body-table">
        <table class="layui-table layui-form">
            <thead>
            <tr>
                {if !$isearch}
                <th rowspan="2"></th>
                {/if}
                <th rowspan="2" colspan="2" class="maxtd">放送日期</th>
                <th rowspan="2">话数</th>
                <th rowspan="2">番剧类型</th>
                <th rowspan="2">制作类型</th>
                <th rowspan="2">标题(中文)</th>
                <th rowspan="2">标题(日文)</th>
                <th rowspan="2">播出频道</th>
                <th rowspan="2">剧集长度</th>
                <th rowspan="2" class="maxtd">漫画对应（总话数）</th>
                <th rowspan="2" class="maxtd">漫画对应（单行本）</th>
                <th colspan="14">正片</th>
                <th colspan="8">OP</th>
                <th colspan="8">ED</th>
                <th rowspan="2">出场者</th>
            </tr>
            <tr>
                <th>
                    <p class="zh">导演</p>
                    <p class="jp">監督</p>
                </th>
                <th>
                    <p class="zh">编剧</p>
                    <p class="jp">脚本</p>
                </th>
                <th>
                    <p class="zh">构成</p>
                    <p class="jp">構成</p>
                </th>
                <th>
                    <p class="zh">分镜</p>
                    <p class="jp">絵コンテ</p>
                </th>
                <th>
                    <p class="zh">演出</p>
                    <p class="jp">演出</p>
                </th>
                <th>
                    <p class="zh">作画导演</p>
                    <p class="jp">作画監督</p>
                </th>
                <th>
                    <p class="zh">作画监修</p>
                    <p class="jp">作画監修</p>
                </th>
                <th class="maxtd">
                    <p class="zh">作画导演助理</p>
                    <p class="jp">作画監督補佐</p>
                </th>
                <th>
                    <p class="zh">总作画导演</p>
                    <p class="jp">総作画監督</p>
                </th>
                <th class="maxtd">
                    <p class="zh">角色设计</p>
                    <p class="jp">キャラクターデザイン</p>
                </th>
                <th class="maxtd">
                    <p class="zh">副角色设计</p>
                    <p class="jp">サブキャラクターデザイン</p>
                </th>
                <th>
                    <p class="zh">色彩设计</p>
                    <p class="jp">色彩設計</p>
                </th>
                <th>
                    <p class="zh">色指定</p>
                    <p class="jp">色指定</p>
                </th>
                <th>
                    <p class="zh">原画</p>
                    <p class="jp">原画</p>
                </th>
                <th>
                    <p class="zh">编号</p>
                    <p class="jp"></p>
                </th>
                <th>
                    <p class="zh">曲名</p>
                    <p class="jp"></p>
                </th>
                <th>
                    <p class="zh">OP歌手</p>
                    <p class="jp">OP组合</p>
                </th>
                <th>
                    <p class="zh">OP分镜</p>
                    <p class="jp">OP絵コンテ</p>
                </th>
                <th>
                    <p class="zh">OP演出</p>
                    <p class="jp">OP演出</p>
                </th>
                <th>
                    <p class="zh">OP作画导演</p>
                    <p class="jp">OP作画監督</p>
                </th>
                <th class="maxtd">
                    <p class="zh">OP总作画导演</p>
                    <p class="jp">OP総作画監督</p>
                </th>
                <th>
                    <p class="zh">OP原画</p>
                    <p class="jp">OP原画</p>
                </th>
                <th>
                    <p class="zh">编号</p>
                    <p class="jp"></p>
                </th>
                <th>
                    <p class="zh">曲名</p>
                    <p class="jp"></p>
                </th>
                <th>
                    <p class="zh">ED歌手</p>
                    <p class="jp">ED组合</p>
                </th>
                <th>
                    <p class="zh">ED分镜</p>
                    <p class="jp">ED絵コンテ</p>
                </th>
                <th>
                    <p class="zh">ED演出</p>
                    <p class="jp">ED演出</p>
                </th>
                <th>
                    <p class="zh">ED作画导演</p>
                    <p class="jp">ED作画監督</p>
                </th>
                <th class="maxtd">
                    <p class="zh">ED总作画导演</p>
                    <p class="jp">ED総作画監督</p>
                </th>
                <th>
                    <p class="zh">ED原画</p>
                    <p class="jp">ED原画</p>
                </th>

            </tr>
            </thead>
            <tbody id="tvtbody">
                {php}
                $datas = $lists->toArray()["data"];
                {/php}
                {volist name="$datas" id="value"}
                {php}
                $redcolor = false;
                if($value["add_time"]){
                    $theyear = date("Y",$value["add_time"]);
                    $nextdata = isset($datas[$key+1])?$datas[$key+1]:null;
                    if($nextdata){
                        $nextyear =date("Y",$nextdata["add_time"]);
                        if($theyear!=$nextyear){
                            $redcolor = true;
                        }
                    }
                }
                {/php}
                <tr class="tr_{$value.id}{if $redcolor} redcolor {/if} {if $value.display eq 0} dls{/if}{if $value.make_cat eq 4} cb_{$value.fan_cat}{/if}">
                    {if !$isearch}
                    <td>
                        <a href="javascript:;" class="editbtn" onclick="xadmin.open(null,'{:url("tv/post")}?id={$value.id}')">编辑</a>
                        <div style="display: none;" class="selone"><input type="checkbox" name="selone" value="{$value.id}" lay-filter="selone" lay-skin="primary" ></div>
                    </td>
                    {/if}
                    <td>
                        {if $value.add_time}
                        {:date('Y年n月j日',$value['add_time'])}
                        {/if}
                    </td>
                    <td>
                        {if $value.add_time}
                        星期{:formatWeek(date('w',$value['add_time']))}
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if $value.fan_cat}
                        {switch $value.fan_cat}
                        {case 1}第{$value.quarter}季 第{$value.words1}话{/case}
                        {case 2}第{$value.words1}话{/case}
                        {case 3}
                        {if $value.special_cat}
                        第{$value.words1}话~第{$value.words2}话
                        {else}
                        第{$value.words2}部
                        {/if}
                        {/case}
                        {case 4}
                        {if $value.tvlenth eq 2}
                        特{$value.words1}
                        {else}
                        M{$value.words1}
                        {/if}
                        {/case}
                        {case 5}
                        OVA{$value.words1}
                        {/case}
                        {/switch}
                        {else}
                        第{$value.words1}话
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {switch $value.fan_cat}
                        {case 1}季番{/case}
                        {case 2}常规番{/case}
                        {case 4}电影{/case}
                        {case 5}OVA{/case}
                        {/switch}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {switch $value.make_cat}
                        {case 1}原作漫改{/case}
                        {case 2}动画原创{/case}
                        {case 3}停播{/case}
                        {case 4}
                        重播
                        {/case}
                        {/switch}
                    </td>

                    <td>{if $value.make_cat neq 3}{$value.title}{else}/{/if}</td>
                    <td>{if $value.make_cat neq 3}{$value.title_jp}{else}/{/if}</td>
                    <td>
                        {if $value.make_cat neq 3}
                        {php}
                        if($value['tvstation']){
                           $channels = \think\facade\Db::name("channel")->whereIn('id',$value['tvstation'])->select();
                        }else{
                           $channels = [];
                        }
                        {/php}
                        {if $channels}
                        {volist name="channels" id="cha"}
                        <div style="">
                            {if $cha.logo}<img src="{$cha.logo|formatImg}" alt="" width="20">{/if}
                            {$cha.title}
                        </div>
                        {/volist}
                        {else}
                        /
                        {/if}

                        {else}/{/if}</td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if $value.tvlenth}
                        {if $value.tvlenth eq 1}
                        常规25分钟
                        {else}
                        {$value.tvother}小时特别篇
                        {/if}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if $value.comics_words_file1}
                        File.{$value.comics_words_file1}
                        {if $value.comics_words_file2}
                        ~{$value.comics_words_file2}
                        {/if}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if $value.comics_rolls_1}
                        第{$value.comics_rolls_1}卷 File.{$value.comics_rolls_1_file}
                        {if $value.comics_rolls_2}
                        ~ {if $value.comics_rolls_2 neq $value.comics_rolls_1}第{$value.comics_rolls_2}卷  File.{/if}{$value.comics_rolls_2_file}
                        {/if}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][1] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][2] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][3] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][4] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][5] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][6] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][7] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][8] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][9] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][10] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][11] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][12] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][13] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][14] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>{if $value.make_cat neq 3}{$value.op_code}{else}/{/if}</td>
                    <td>{if $value.make_cat neq 3}{$value.op_title}{else}/{/if}</td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][15] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][16] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][17] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][18] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][19] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][20] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>{if $value.make_cat neq 3}{$value.ed_code}{else}/{/if}</td>
                    <td>{if $value.make_cat neq 3}{$value.ed_title}{else}/{/if}</td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][21] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][22] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][23] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][24] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][25] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat neq 3}
                        {if count($value['staff'])>=1}
                        {foreach $value['staff'][26] as $v}
                        <span class="zh">{$v.uname}</span> <span class="jp">{$v.uname_jp}</span> <br>
                        {/foreach}
                        {/if}
                        {else}
                        /
                        {/if}
                    </td>
                    <td>
                        {if $value.make_cat!=3}
                        <a href="javascript:;" onclick="xadmin.open('声优查看','{:url("tv/seiyuu",["id"=>$value['id']])}')">点击查看</a>
                        {else}
                        /
                        {/if}
                    </td>
                </tr>
                {/volist}
            </tbody>
        </table>

    </div>
    <div class="layui-card-body ">
        {$lists|raw}
    </div>
</div>

<script>

    function addstaff(id) {
        var html2=''
        html2 +=`<div class="layui-inline stafflists" data-cat="">`
        html2 +=`<input type="text" name="staff"  value="" autocomplete="off" class="layui-input inline nosel" placeholder="请输入">`
        html2 +='</div>'
        $('.staff_lists').append(html2)
    }
    function substaff(id) {
        $('.staff_lists>.layui-inline:last-child').remove()
    }

    function del() {
        var id;
        let seltype = $('.selobj').data("type")
        if(seltype==="sel"){
            id = [$('[name="selone"]').last().val()]
        }else{
            id = getselall()
        }

        layer.confirm("{:lang('del.confirm')}",{icon: 3, title:'{:lang("tips")}'},function (index) {
            layer.close(index);
            request("POST",'{:url("tv/del")}',{
                id:id
            },function (res) {
                window.location.reload()
            })

        })
    }
    function addline() {
        request("POST",'{:url("tv/add")}',{work_id:id},function (res,msg) {
            var html
            html +=`<tr class="tr_${res.id}">`
            html +='<td>'
            html +=`<a href="javascript:;" class="editbtn" onclick="xadmin.open('{$item.title}','{:url("tv/post")}?id=${res.id}')">编辑</a>`
            html +=`<div style="display: none;" class="selone"><input type="checkbox" name="selone" value="${res.id}" lay-skin="primary" /></div>`
            html +='</td>';
            for(var i = 1;i<=41;i++){
                if(i==3){
                    html +=`<td>第${res.words1}话</td>`
                }else{
                    html +=`<td></td>`
                }
            }
            html +=`</tr>`
            window.location.reload();
            // $('#tvtbody').append(html)

        })
    }


</script>

